import request from '../utils/request'
/**
 *  实例方法
 *  request.getRequest(url, config)
 *  request.postRequest(url, config)
 *  request.putRequest(url, config)
 *  request.deleteRequest(url, config)
 *  request.headRequest(url, config)
 *  request.optionsRequest(url, config)
 *  request.traceRequest(url, config)
 *  request.connectRequest(url, config)
 *  使用说明
 *   https://github.com/skyvow/wx-extend/blob/master/docs/components/request.md
 */
//拉取购物车列表
export function getShopCartList(cartQuery) {
	return request.postRequest('/mall/mobile/cart/query_list', {
		data: {
			...cartQuery

		}
	})
}
//更新商品数量
export function updateItemNum(cartUpdateGoodsNum) {
	return request.postRequest('/mall/mobile/cart/update_item_num', {
		data: {
			...cartUpdateGoodsNum

		}
	})
}

//删除购物车商品
export function deleteItem(cartItemDel) {
	return request.postRequest('/mall/mobile/cart/del_item', {
		data: {
			...cartItemDel

		}
	})
}

//批量删除购物车商品
export function batchDeleteItem(delList) {
	return request.postRequest('/mall/mobile/cart/batch_del_item', {
		data: delList
	})
}

//获取购物车商品数量
export function cartListCount(data) {
	if (data && data.deliveryType) {
		return request.getRequest('/mall/mobile/cart/count?type=' + data.deliveryType)
	} else if (data && data.storeId) {
		return request.getRequest('/mall/mobile/cart/count?storeId=' + data.storeId)
	}

	else {
		return request.getRequest('/mall/mobile/cart/count')
	}

}

//改变选择状态
export function changeSelectState(cartChangeSelect) {
	return request.postRequest('/mall/mobile/cart/change_select_status', {
		data: cartChangeSelect
	})
}

//添加商品到购物车
export function addGoodsToCart(cartAddForm) {
	return request.postRequest('/mall/mobile/cart/add_item', {
		data: cartAddForm
	})

}












